<%-- 
    Document   : FTravelTip
    Created on : 29/04/2010, 14:09:40
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="br.terminalrodoviario.TravelTip"%>
<%@page import="java.util.*, java.text.*" %>
<jsp:useBean class="br.terminalrodoviario.TravelTip" id="TravelTip" scope="page"/>
<%
            String id = request.getParameter("id");
            if (id != null) {
                TravelTip = new TravelTip().selectById("select n from TravelTip n where n.id = " + id);
            }
%>

<jsp:useBean class="br.terminalrodoviario.User" id="user" scope="session"/>
<%
        if (user.getId() == 0) {
            response.sendRedirect("../login.jsp");
        }
%>

<script type="text/javascript">
    function verifyFields(){
        var txtTitle = document.getElementById("txtTitle");
        var txtSubtitle = document.getElementById("txtSubtitle");
        var txtDate = document.getElementById("txtDate");
        document.getElementById('validate').innerHTML = '';
        document.getElementById('validate1').innerHTML = '';
        document.getElementById('validate2').innerHTML = '';
        var fill = true;

        var expReg = /^(([0-2]\d|[3][0-1])\/([0]\d|[1][0-2])\/[1-2][0-9]\d{2})$/;
        if (!((txtDate.value.match(expReg)) && (txtDate.value!=''))) {
            document.getElementById('validate2').innerHTML = 'Formato inválido de data';
            fill=false;
            txtDate.focus();
        }

        if(txtTitle.value==""){
            document.getElementById('validate').innerHTML = 'Informe o título';
            fill=false;
        }
        if(txtSubtitle.value==""){
            document.getElementById('validate1').innerHTML = 'Informe o subtítulo';
            fill=false;
        }
        if(txtDate.value==""){
            document.getElementById('validate2').innerHTML = 'Informe a data';
            fill=false;
        }
        if(fill==false)
            return;
        document.getElementById("form").submit();
    }

</script>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Guia Terminal Rodoviário</title>
        <%SimpleDateFormat formatBra = new SimpleDateFormat("dd/MM/yyyy");%>
        <style type="text/css">
            @import url("../../add/css/cssAdmin.css");
            @import url("../../add/css/rodape.css");
        </style>
    </head>
    <body>
        <div class="geral">
            <table>
                <tr>
                    <td>
                        <div id="cabecalho">
                        </div>
                    </td>
                </tr>
            </table>
            <table id="menuAdmin" width="762">
                <tr >
                    <td>
                        <ul class="menuCidade" >
                            <li><a href="../Manager/MCity.jsp" /></li>
                        </ul>
                    </td>
                    <td>
                        <ul class="menuEmpresa" >
                            <li><a href="../Manager/MCompany.jsp" /></li>
                        </ul>
                    </td>
                    <td>
                        <ul class="menuTerminais" >
                            <li><a href="../Manager/MBusStation.jsp" /></li>
                        </ul>
                    </td>
                    <td>
                        <ul class="menuHoteis" >
                            <li><a href="../Manager/MHotel.jsp" /></li>
                        </ul>
                    </td>
                    <td>
                        <ul class="menuNoticias" >
                            <li><a href="../Manager/MNotice.jsp" /></li>
                        </ul>
                    </td>
                    <td>
                        <ul class="menuSolicitacao" >
                            <li><a href="../Manager/MSolicitation.jsp" /></li>
                        </ul>
                    </td>
                    <td>
                        <ul class="menuDicas" >
                            <li class="current"><a href="../Manager/MTravelTip.jsp" /></li>
                        </ul>
                    </td>

                </tr>
            </table>

            <div style="float:left">
                <br/>
                <b><a href="../index.jsp">Início</a> -> <a href="../Manager/MTravelTip.jsp">Dicas de Viagem</a> -> <a href="FTravelTip.jsp">Cadastrar Dica de Viagem</a></b>
                <br/><br/>
            </div>
            <div align="right" style="font-family:calibri; font-size:11px; font-style:inherit">
                <br/>Bem-vindo <b><%=request.getSession().getAttribute("username")%></b>,<br/>
                você está logado desde <%=request.getSession().getAttribute("date_session")%>h. ( <a href="../logout.jsp"><b>Logout</b></a> )<br/><br/>
            </div>

            <table  id="subTitulo">
                <tr>
                    <td id="icone">
                        &nbsp;&nbsp;&nbsp;&nbsp;<img src="../../add/images/icones/travel_tips.png" alt="Dicas de Viagem" title="Dicas de Viagem"/>
                    </td>
                    <td>
                        Dicas de Viagem
                    </td>
                </tr>
            </table>
            <br>

            <form id="form" action="../TravelTipServlet?acao=gravar&id=<%=request.getParameter("id")%>" method="post">
                <div align="right"><b style="color:red">(*) campos obrigatórios</b></div>
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td class="label_bg" style="width:150px;">&nbsp;&nbsp;Título:</td>
                        <td>&nbsp;&nbsp;<input type="text" id="txtTitle" name="txtTitle" value="<%=TravelTip.getTitle() == null ? "" : TravelTip.getTitle()%>" size="70"> <b style="color:red">*</b> <b id="validate"></b></td>
                    </tr>
                    <tr>
                        <td class="label">&nbsp;&nbsp;Subtítulo:</td>
                        <td>&nbsp;&nbsp;<input type="text" id="txtSubtitle" name="txtSubtitle" value="<%=TravelTip.getSubtitle() == null ? "" : TravelTip.getSubtitle()%>" size="70"> <b style="color:red">*</b> <b id="validate1"></b</td>
                    </tr>
                    <tr>
                        <td class="label_bg" style="width:150px;">&nbsp;&nbsp;Data:</td>
                        <td>&nbsp;&nbsp;<input type="text" id="txtDate" name="txtDate" value="<%=TravelTip.getDatePublished() == null ? formatBra.format(new java.util.Date()) : formatBra.format(TravelTip.getDatePublished())%>" size="70"> <b style="color:red">*</b> <b id="validate2"></b</td>
                    </tr>
                    <tr>
                        <td class="label" valign="top">&nbsp;&nbsp;Conteúdo:</td>
                        <td>&nbsp;&nbsp;<textarea name="txtContent" rows="5" cols="35" style="width:445px">
                                <%=TravelTip.getContent() == null ? "" : TravelTip.getContent()%>
                            </textarea>
                        </td>
                    </tr>
                </table>
                <table>
                    <tr>
                        <td align="right" colspan="2" width="605"><input type="button" onclick="javascript:verifyFields();" align="right" value="Gravar" name="enviar"><br></td>
                    </tr>
                </table>
            </form>
            <br>
            <table id="rodape" style="background-image:url(../../add/images/rodape.png);">
                <tr>
                </tr>
            </table>
            <table id="btRodape" style="text-decoration: none;" >
                <tr>
                    <td align="center" width="80px">
                        <ul class="btYoutube">
                            <li><a title="Youtube" href="http://www.youtube.com" /></li>
                        </ul>
                    </td >
                    <td align="center" width="80px">
                        <ul class="btOrkut">
                            <li><a title="Orkut" href="http://www.orkut.com" /></li>
                        </ul>
                    </td>
                    <td align="center" width="205px">
                        <ul class="btTwitter">
                            <li><a title="Twitter" href="http://twitter.com" /></li>
                        </ul>
                    </td>
                    <td align="center">
                        <a title="Trabalhe Conosco" class="text" href="../../Carrer.jsp" >Trabalhe Conosco</a>
                    </td>
                    <td align="center"  width="">
                        <a title="Mapa do Site" class="text" href="../../SiteMap.jsp">Mapa do Site</a>
                    </td>
                    <td align="center" width="">
                        <a title="Contatos" class="text" href="../../Contact.jsp">Contatos</a>
                    </td>
                </tr>
            </table>
        </div>
    </body>
</html>
